package com.chuyu.jzwboa.fragment.main;


import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.chuyu.jzwboa.R;
import com.chuyu.jzwboa.activity.log.MyLogActivity;
import com.chuyu.jzwboa.activity.mailist.MailListActivity;
import com.chuyu.jzwboa.activity.notice.NoticeActivity;
import com.chuyu.jzwboa.activity.offciemobile.OffDocManageActivity;
import com.chuyu.jzwboa.activity.testqinmanage.HitCardRecordActivity;
import com.chuyu.jzwboa.adapter.main.MainOfficeAdapter;
import com.chuyu.jzwboa.base.MVPBaseFragment;
import com.chuyu.jzwboa.presenter.main.MainFragPresnter;
import com.chuyu.jzwboa.view.iview.main.IMainFragmentView;
import com.facebook.imageformat.ImageFormat;

import butterknife.BindView;

/**
 * @author 杨仕俊
 * @description 首页fragment
 * Created by wo on 2017/12/15.
 */

public class MainFragment extends MVPBaseFragment<IMainFragmentView, MainFragPresnter>
		implements IMainFragmentView, AdapterView.OnItemClickListener {
	@BindView(R.id.gradView_office)
	GridView gradViewOffice;
	@BindView(R.id.ll_mobile_off)
	LinearLayout llMobileOff;
	@BindView(R.id.gradView_msg)
	GridView gradViewMsg;

	private int imgOffice[] = new int[]{R.mipmap.icon_doc_1, R.mipmap.icon_knowls_1,
			R.mipmap.icon_knowls_2, R.mipmap.icon_doc_2,
			R.mipmap.icon_knowls_2, R.mipmap.icon_share_2};

	private String strOffice[] = new String[]{"协同办公", "公文管理", "站内邮件",
			"工作日志", "考勤管理", "通讯录"};

	private int imgMsg[] = new int[]{R.mipmap.icon_sys_1, R.mipmap.icon_knowls_1,
			R.mipmap.icon_doc_2};

	private String strMsg[] = new String[]{"通知公告", "文档中心", "新闻中心"};

	@Override
	protected void initView() {
		MainOfficeAdapter mainAdapter = new MainOfficeAdapter(getActivity(), imgOffice, strOffice);
		gradViewOffice.setAdapter(mainAdapter);
		MainOfficeAdapter mainAdapters = new MainOfficeAdapter(getActivity(), imgMsg, strMsg);
		gradViewMsg.setAdapter(mainAdapters);

	}

	@Override
	protected void initData() {
		gradViewOffice.setOnItemClickListener(this);
		gradViewMsg.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
				switch (i) {
					//通知公告
					case 0:
						startActivity(new Intent(getActivity(), NoticeActivity.class));
						break;
				}
			}
		});
	}

	@Override
	protected int initContentLayout() {
		return R.layout.fragment_main;
	}

	@Override
	public MainFragPresnter createPresenter() {
		return new MainFragPresnter();
	}


	@Override
	public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
		switch (i) {
			case 1:
				startActivity(new Intent(getActivity(), OffDocManageActivity.class));
				break;
			case 3:
				//我的日志
				startActivity(new Intent(getActivity(), MyLogActivity.class));
				break;
			case 4:
				//打卡记录
				startActivity(new Intent(getActivity(), HitCardRecordActivity.class));
				break;
			case 5:
				//通讯录
				startActivity(new Intent(getActivity(), MailListActivity.class));
				break;
		}
	}
}
